﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Electronic_work_order.Interfacess.OA_Ordering;
using Electronic_work_order.Model;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Electronic_work_order.Controllers
{
    [ApiController]
    public class OA_OrderingController : ControllerBase
    {
        private readonly IOrdering _ordering;

        public OA_OrderingController(IOrdering ordering)
        {
            _ordering = ordering;
        }
        //添加数据
        [HttpPost]
        [Route("[controller]/AddOrdering")]
        public int AddOrdering(Ordering ordering)
        {
            int count = _ordering.AddOrdering(ordering);
            if (count>0)
            {
                return 1;
            }
            else
            {
                return 0;
            }
        }

        //显示所有状态信息
        [HttpGet]
        [Route("[controller]/GetOrderState")]
        public IEnumerable<OrderState> GetOrderState()
        {
            return _ordering.GetOrderState();
        }

        //显示所有套餐
        [HttpGet]
        [Route("[controller]/GetSet_meal")]
        public IEnumerable<Set_meal> GetSet_meal()
        {
            return _ordering.GetSet_meal();
        }
    }
}
